import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import axios from 'axios'
import CommonHead from './components/CommonHead.vue'
import CommonFooter from './components/CommonFooter.vue'
import 'vant/lib/index.css'
import './assets/gloable.css'
import Vant, { Lazyload, Overlay, Form, Popup, DropdownMenu, Toast } from 'vant'
import 'font-awesome/css/font-awesome.css'
import './assets/icon/iconfont.css'
import moment from 'moment'
// 引入地图组件
import BaiduMap from 'vue-baidu-map'
// 引入mock数据 地图
import './mock/index'

import './mock/vedio'

import './mock/video_address'
import VideoPlayer from 'vue-video-player'
import './mock/feedback'

// 定义全局公共评论组件
import Comment from './components/comment.vue'
Vue.component('comment', Comment)

Vue.component('common-head', CommonHead)
Vue.component('common-footer', CommonFooter)

// 默认地址
axios.defaults.baseURL = 'http://api.cms.liulongbin.top'
Vue.use(VideoPlayer)
Vue.use(Lazyload)
Vue.use(Vant)
Vue.use(Form)
Vue.use(Popup)
Vue.use(DropdownMenu)
Vue.config.productionTip = false
axios.defaults.baseURL = 'http://api.cms.liulongbin.top'
Vue.prototype.$http = axios

// 默认地址
axios.defaults.baseURL = 'http://api.cms.liulongbin.top'

// Vue.use(ImagePreview)

Vue.use(Overlay)

Vue.use(Lazyload, {
  lazyComponent: true
})

Vue.component('comment', Comment)
Vue.prototype.$http = axios
Vue.prototype.$toast = Toast
axios.defaults.baseURL = 'http://api.cms.liulongbin.top'

Vue.use(Vant)
Vue.use(BaiduMap, {
  ak: 'OGvrE3c3ea4SNlTkU7rOjk0smhB34FFA'
})
Vue.config.productionTip = false

// // 挂载路由导航守卫路由拦截
// router.beforeEach((to, from, next) => {
//   // to将要访问的路径
//   // from代表从哪个路径跳转而来
//   // next是一个函数，表示放行
//   // next()放行next('/login')强制跳转
//   const reg = /(iPhone|iPad|iPod|iOS|Android)/i
//   if (to.path === '/login' || to.path === '/mobilelogin' || to.path === '/verificationlogin') return next()

//   const islogin = window.sessionStorage.getItem('isLogin')
//   if (!islogin) {
//     if (reg.test(navigator.userAgent)) {
//       return next('/login')
//     } else {
//       return next('/#/mobilelogin')
//     }
//   }

//   //   window.location.href = reg.test(navigator.userAgent) ? '/#/mobilelogin' : '/login'
//   next()
// })

// 默认地址

Vue.filter('dateformat', function (value, format) {
  return moment(value).format(format)
})
new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
